#! /usr/bin/env node

const fs = require('fs');
const path = require('path');
// // 简单读文件
// if (fs.statSync(path.join(process.cwd(), process.argv[2]))) {
//     console.log(fs.readFileSync(path.join(process.cwd(), process.argv[2]), 'utf-8'));
// }

//cat 和 递归
function readF(url) {
    let arr = fs.readdirSync(url);
    arr.forEach(item => {
        if (fs.statSync(path.join(url, item)).isDirectory()) {
            readF(path.join(url, item))
        } else {
            console.log(fs.readFileSync(path.join(url, item), 'utf-8'))
        }
    })
}

readF(__dirname);

//mkdir

fs.mkdirSync(path.join(__dirname, 'abc'))

//touch

fs.writeFileSync('./touch.txt', '1111');